Release 10.1A: OpenEdge Data Management:
DataServer for Microsoft SQL Server
Run Stored-Proc statement execution using the send-sql-statement option
The Progress 4GL also allows you to use stored-procedure syntax to send SQL statements and their native language extensions directly to a data source. The DataServer uses the
RUNSTORED–PROCEDUREstatement with thesend–sql–statementoption to pass SQL statements to the data source. This option gives you access to Transact–SQL, providing you access to business logic for MS SQL Server. For example, you can issue Data Definition Language (DDL) statements from within Progress procedures. You can send multiple SQL statements by concatenating them and passing the string as a single parameter to thesend–sql–statementoption.Like the option to define a
RUN STORED-PROCstatement either with or without theLOAD-RESULT-INTOoptions, you can define a send-sql-statement with or without theLOAD-RESULT-INTOoption. The following section presents and briefly describes a sample use of each technique.Without the Load-Result-Into option
You use the
RUNSTORED–PROCstatement with thesend–sql–statementoption and pass the Transact-SQL statements as a parameter. The syntax of the statement must be valid Transact-SQL syntax. Example 3–1 shows how this code passes aSELECTstatement as a parameter.
Example 3–1: Passing a SELECT statement as a parameterExample 3–1 returns the
name,address,city,state, andpostal_codefor allcustomerswhosemax–creditis greater than or equal to $500. You must read the results into a buffer as you would with a stored procedure called by a Progress procedure. You can read the results into theproc–text–bufferdefined by Progress as shown in the example above. Alternatively, you can define your own buffer from within your data source that can accept other data types as well as theCHARACTERdata type.With the Load-Result-Into option
Example 3–2 shows how to use the send-sql-statement with the
LOAD-RESULT-INTOoption. It also shows that thePROC-STATUSphrase must be defined as part of theRUN STORED-PROCstatement because of the implicitCLOSE STORED-PROCthat is associated with theLOAD-RESULT-INTOphrase.
Example 3–2: Using the send-sql-statement with the LOAD-RESULT-INTO optionAlso note in Example 3–2 that the
PROC-STATUSphrase does not need an associatedPROC-HANDLEphrase to close the associated procedure because it is retrieved using theRUN STORED-PROCstatement; although thePROC-HANDLEis typically used after the execution of theRUN STORED-PROCstatement, it is not needed in this context because of the implicit procedure close.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |